//本地执行，所有单位都能触发
params ["_killed", "_killer"];

//开启了血腥效果
if (Param_Blood == 1
&& {_killed isKindOf "CAManBase"}
&& {((typeof _killed) find "_UAV_AI") < 0})then
{
	//ai死亡音效
	if((!isPlayer _killed)
		&& {_killed distanceSqr player < 400})then{
		private _veh = "#particlesource" createVehicleLocal ASLToAGL getPosWorld _killed;
		_veh say3D (selectRandom ast_pain);
	};

	//血池效果
	_killed spawn {
		sleep 1;
		private _pos = getPosASL _this;
		
		private _type = selectRandom ase_blood_pool;
		private	_veh = _type createVehicleLocal [0,0,0];

		_veh setDir (random 360);
		_veh setVehiclePosition [_pos, [], 0, "CAN_COLLIDE"];


		//转化为简单对象，本地的简单对象1.9才支持
		if(Param_Version >= 183)then
		{
			private _position = getPosWorld _veh;
			private _vectorDirUp = [vectorDir _veh, vectorUp _veh];
			
			deleteVehicle _veh;
			_veh = createSimpleObject [_type, _position, true];
			_veh setVectorDirAndUp _vectorDirUp;
		};
	};
};

//自杀或者 关闭了击杀提示
if(_killed == _killer
|| {Param_Killfeed == 0}) exitWith{};



//击杀提示
if (_killer == player
|| {_killer == vehicle player}) then
{
	//直接调用side无法正确返回
	if ((_killed isKindOf "CAManBase"))then{
		if((side group _killer) getFriend (side group _killed) < 0.6)then
		{
			//死者名字
			private _killed_Name = "";
			if (!(isplayer _killed)) then {
				_killed_Name = getText (configFile >> "CfgVehicles" >> format["%1",typeOf _killed] >> "Displayname");
			}else{
				_killed_Name = name _killed
			};
			
			//死者颜色
			private _killed_Color = "#99D5FF";
			_killed_Color = (side group _killed call BIS_fnc_sideColor) call BIS_fnc_colorRGBtoHTML;


			//武器名字
			private _weaponName = getText(configFile >> "CfgWeapons" >> currentWeapon (vehicle _killer) >> "displayname");
			if(_weaponName == "喇叭")then{
				_weaponName = "载具";
			};
			if(_weaponName == "")then{
				_weaponName = "武器";
			};
			
			//武器图像
			private	_pictureweapon = "";
			private _weapon = currentWeapon _killer;
			if(_weapon != "")then{
				_pictureweapon = gettext (configFile >> "cfgWeapons" >> _weapon >> "picture");
			};


			private _kill_HUD = format["<t size='0.5'>干掉了  <t size='0.8'> <t color='%1'>  %2</t>", _killed_Color, _killed_Name];	


			//玩家击杀提示
			[_kill_HUD,0,0.3,2,0,0,7017] spawn bis_fnc_dynamicText;

			//左下角
			[format["%1  击杀了  %2  使用  %3", name player, _killed_Name, _weaponName]] remoteExec ["systemChat", 0];
			
			// 左上信息	
			private _kill_info = "";
			if(_pictureweapon == "")then{
				_kill_info = format["  %1  击杀了  <t color='%2'>  %3  <t color='#FFD700'>  使用  <t color='#FF0000'>  %4</t>",
					name _killer,
					_killed_Color,
					_killed_Name,
					_weaponName];
			}else{
				_kill_info = format["<img size='1' shadow='1' image='%1'/>  %2  击杀了  <t color='%3'>  %4  <t color='#FFD700'>  使用  <t color='#FF0000'>  %5</t>",
					_pictureweapon,
					name _killer,
					_killed_Color,
					_killed_Name,
					_weaponName];
			};

			
			[["<t size='0.6' align='left'>" + _kill_info + "</t>",safeZoneX,safeZoneY,10,0,0,7016] remoteExec ["BIS_fnc_dynamicText",0,false]];

			
			playSound "Killfeed_notification";

			//加钱
			private _money = player getVariable["as_money", 0];
			private _add = Param_Money_kill;
			if(isplayer _killed)then
			{
				_add = 100;
			};
			player setVariable["as_money",  _money + _add, true];
		}
		else{
			//扣钱
			private _money = player getVariable["as_money", 0];
			player setVariable["as_money",  _money - Param_Money_tk, true];
			
			[player, format["击杀了非敌对单位  %1", getText (configFile >> "CfgVehicles" >> format["%1",typeOf _killed] >> "Displayname")]] remoteExec ["globalChat", 0];
		};
	};
};				